#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>



int main()
{
  printf("my program is running\n");

  int pid = fork();
  if(pid == 0)
  {
    //printf("begin! child pid is: %d\n", getpid());
    sleep(1);
    //execl("/usr/bin/ls", "ls", "-l", NULL);
    //execlp("ls", "ls", "-l", NULL);
    char* const envp[] = {
      (char* const)"MYVAL=123456789",
      NULL 
    };

    //有疑问
    //execle("./mytest", "mytest", "-a", NULL, env);

    char* const argv[] = {
      //(char* const)"ls",
      //(char* const)"-l",
      (char* const)"other",
      (char* const)"-a",
      (char* const)"-b",
      NULL
    };
    //execv("/usr/bin/ls", argv);
    
    //execvp("ls", argv);
    
    execvpe("./mytest", argv, envp);
    
    //printf("end!\n");
    //exit(1);
  }


  waitpid(-1, NULL, 0);
  //printf("my child pid is:%d\n", pid);
  printf("my program is done\n");
  //return 0;
}
